package com.hongxun.modules.eys.service.impl;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.hongxun.modules.eys.dao.EDrawLineDao;
import com.hongxun.modules.eys.entity.EDrawLineEntity;
import com.hongxun.modules.eys.service.EDrawLineService;



@Service("eDrawLineService")
public class EDrawLineServiceImpl implements EDrawLineService {
	@Autowired
	private EDrawLineDao eDrawLineDao;
	
	@Override
	public EDrawLineEntity queryObject(String guid){
		return eDrawLineDao.queryObject(guid);
	}
	
	@Override
	public List<EDrawLineEntity> queryList(Map<String, Object> map){
		return eDrawLineDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return eDrawLineDao.queryTotal(map);
	}
	
	@Override
	public void save(EDrawLineEntity eDrawLine){
        if(eDrawLine.getGuid()==null||eDrawLine.getGuid().equals("")) {

		    eDrawLine.setGuid(UUID.randomUUID().toString());
        }
		eDrawLineDao.save(eDrawLine);
	}
	
	@Override
	public void update(EDrawLineEntity eDrawLine){
		eDrawLineDao.update(eDrawLine);
	}
	
	@Override
	public void delete(String guid){
		eDrawLineDao.delete(guid);
	}
	
	@Override
	public void deleteBatch(String[] guids){
		eDrawLineDao.deleteBatch(guids);
	}

	@Override
	public void insertOrReplaceOrDelete(List<EDrawLineEntity> entities) {
		for (EDrawLineEntity d : entities) {
			if (d.getDLDatastate().equals("删除")) {
				eDrawLineDao.delete(d.getGuid());
			} else {
				EDrawLineEntity eDrawLineEntity = eDrawLineDao.queryObject(d.getGuid());
				if (eDrawLineEntity == null) {
					eDrawLineDao.save(d);
				} else {
					eDrawLineDao.update(d);
				}
			}
		}
	}
	
}
